Skip to content

Conversation

@ScribbleTAS
Copy link
Member

@ScribbleTAS ScribbleTAS commented Jun 23, 2025

It's always fascinating on how much you learn when trying to fix issues like this...

If start a world and it has a "resources.zip" in the world folder, it is widely known that Minecraft will attempt to load this resourcepack. Map makers have been using this feature for a while now...

What I didn't know is that it actually sets up that rp to be a "server resourcepack", so that people joining via LAN also have the same RP.

While the host of the LAN server is accessing this RP directly, the client is only downloading it once to their system and then load it.

So the problem in this case is the host, as loadstates will try to delete the current world and the host, still having access to the RP, will fail to delete it.

So the solution is to:

  1. Unload the RP on the host
  2. Loadstate
  3. Tell all clients (including the "host") to reload the server RP

Unloading the host RP turned out a bit complicated, as unloading a RP schedules multiple actions on a different thread, meaning a future had to be used to make the server wait until the client-host has cleared it's RP.

And that also needed a countdown latch, to make the client wait, as that happens on yet another thread...

Finally a good portion of my time went into figuring out, that a association with a file has to be cleared by running the garbage collector, otherwise savestates would still fail even though the RP was visibly unloaded.

And for good measure, I added a simple warning to the loadstating process if a resources.zip is present, in case anyone is wondering why savestating takes 5 times longer than usual.

The end result is that you can easily load different RPs with savestates, so you can make some creative stuff with different RPs for different sections of something...

Fixes #204

@ScribbleTAS ScribbleTAS self-assigned this Jun 23, 2025
@ScribbleTAS ScribbleTAS added the Savestates Issue is related to savestates label Jun 23, 2025
@github-project-automation github-project-automation bot moved this to Todo in TASmod Jun 23, 2025
@ScribbleTAS ScribbleTAS force-pushed the fix/savestates-resourcepacks branch from 7163bc8 to a2a25e5 Compare June 24, 2025 20:55
@ScribbleTAS ScribbleTAS force-pushed the fix/savestates-resourcepacks branch from 9400a93 to 0ebbfcc Compare July 16, 2025 11:36
@ScribbleTAS ScribbleTAS marked this pull request as ready for review July 16, 2025 11:36
@ScribbleTAS ScribbleTAS moved this from Todo to In Progress in TASmod Jul 16, 2025
@ScribbleTAS ScribbleTAS requested a review from PancakeTAS July 16, 2025 11:36
Specifically, if the resources.zip and the user is loadstating is present,
then it will show a message saying that the loadstating takes severely longer

Added a MessageUtils helper that can split lines with "\n" into multiple lines automatically
@ScribbleTAS ScribbleTAS force-pushed the fix/savestates-resourcepacks branch from 0ebbfcc to 5b91d9e Compare July 16, 2025 11:37
@ScribbleTAS ScribbleTAS merged commit 4b11029 into MinecraftTAS:develop Jul 16, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in TASmod Jul 16, 2025
@ScribbleTAS ScribbleTAS deleted the fix/savestates-resourcepacks branch July 16, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Savestates Issue is related to savestates

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

World with custom resourcepack breaks savestates

2 participants